package com.mydemo.design_pattern.structure_type.adapter_pattern;

import com.mydemo.design_pattern.structure_type.adapter_pattern.impl.FlvPlayer;
import com.mydemo.design_pattern.structure_type.adapter_pattern.impl.Mp4Player;
import org.apache.commons.lang.StringUtils;

/**
 * <p></p >
 *
 * @author liming1
 * @version $Id: IMediaAdapter, v1.0 2019-09-18 16:14 liming1 Exp $
 */
public class MediaAdapter implements IMediaPlayer {
    private AdvanceAudioPlayer advanceAudioPlayer;

    public MediaAdapter(String playerType){
        if (StringUtils.equals(playerType,"flv")){
            advanceAudioPlayer = new FlvPlayer();
        }
        if (StringUtils.equals(playerType,"mp4")){
            advanceAudioPlayer = new Mp4Player();
        }
    }

    @Override
    public void play(String type) {
        advanceAudioPlayer.playAdvance();
    }
}
